using System;
using System.Runtime.InteropServices;

namespace Leap
{
	public class Config : Interface
	{
		public enum ValueType
		{
			TYPE_UNKNOWN,
			TYPE_BOOLEAN,
			TYPE_INT32,
			TYPE_FLOAT = 6,
			TYPE_STRING = 8,
			TYPEUNKNOWN = 0,
			TYPEBOOLEAN,
			TYPEINT32,
			TYPEFLOAT = 6,
			TYPESTRING = 8
		}

		private HandleRef swigCPtr;

		public Config(IntPtr cPtr, bool cMemoryOwn)
			: base(LeapPINVOKE.Config_SWIGUpcast(cPtr), cMemoryOwn)
		{
			swigCPtr = new HandleRef(this, cPtr);
		}

		public static HandleRef getCPtr(Config obj)
		{
			return obj?.swigCPtr ?? new HandleRef(null, IntPtr.Zero);
		}

		~Config()
		{
			Dispose();
		}

		public override void Dispose()
		{
			lock (this)
			{
				if (swigCPtr.Handle != IntPtr.Zero)
				{
					if (base.swigCMemOwn)
					{
						base.swigCMemOwn = false;
						LeapPINVOKE.delete_Config(swigCPtr);
					}
					swigCPtr = new HandleRef(null, IntPtr.Zero);
				}
				GC.SuppressFinalize(this);
				base.Dispose();
			}
		}

		public Config()
			: this(LeapPINVOKE.new_Config(), true)
		{
		}

		public ValueType Type(string key)
		{
			ValueType result = (ValueType)LeapPINVOKE.Config_Type(swigCPtr, key);
			if (LeapPINVOKE.SWIGPendingException.Pending)
			{
				throw LeapPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool GetBool(string key)
		{
			bool result = LeapPINVOKE.Config_GetBool(swigCPtr, key);
			if (LeapPINVOKE.SWIGPendingException.Pending)
			{
				throw LeapPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool SetBool(string key, bool value)
		{
			bool result = LeapPINVOKE.Config_SetBool(swigCPtr, key, value);
			if (LeapPINVOKE.SWIGPendingException.Pending)
			{
				throw LeapPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public int GetInt32(string key)
		{
			int result = LeapPINVOKE.Config_GetInt32(swigCPtr, key);
			if (LeapPINVOKE.SWIGPendingException.Pending)
			{
				throw LeapPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool SetInt32(string key, int value)
		{
			bool result = LeapPINVOKE.Config_SetInt32(swigCPtr, key, value);
			if (LeapPINVOKE.SWIGPendingException.Pending)
			{
				throw LeapPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public float GetFloat(string key)
		{
			float result = LeapPINVOKE.Config_GetFloat(swigCPtr, key);
			if (LeapPINVOKE.SWIGPendingException.Pending)
			{
				throw LeapPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool SetFloat(string key, float value)
		{
			bool result = LeapPINVOKE.Config_SetFloat(swigCPtr, key, value);
			if (LeapPINVOKE.SWIGPendingException.Pending)
			{
				throw LeapPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public string GetString(string key)
		{
			string result = LeapPINVOKE.Config_GetString(swigCPtr, key);
			if (LeapPINVOKE.SWIGPendingException.Pending)
			{
				throw LeapPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool SetString(string key, string value)
		{
			bool result = LeapPINVOKE.Config_SetString(swigCPtr, key, value);
			if (LeapPINVOKE.SWIGPendingException.Pending)
			{
				throw LeapPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool Save()
		{
			return LeapPINVOKE.Config_Save(swigCPtr);
		}
	}
}
